package com.tieba.controller;

import com.tieba.pojo.Mail;
import com.tieba.pojo.Result;
import com.tieba.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mail")
public class SendMailController {

    @Autowired
    private MailService mailService;

    /**
     * 发送文本邮件
     * @param mail
     */
    @PostMapping("/sendTextMail")
    public Result sendTextMail(@RequestBody Mail mail){
        mailService.sendTextMailMessage(mail.getTo(),mail.getSubject(),mail.getText());
        return Result.success();
    }
}
